﻿///系统登陆窗体
Ext.ns("Tk");
Tk.Login = Ext.extend(Ext.form.FormPanel, {
    border: false
					, frame: true
					, labelWidth: 80
					, url: "Login.aspx"
					, initComponent: function() {
					    var config = {
					        baseCls: 'x-plain',

					        defaultType: 'textfield',
					        ///表单输入
					        items: [
								{
								    fieldLabel: '帐号',
								    allowBlank: false,
								    width: 200,
								    blankText: '用户名不能为空',
								    name: 'UserName',
								     emptyText:'用户名不能为空',
								    hideMode: 'display'
								},
								{
								    width: 200,
								    allowBlank: false,
								    fieldLabel: '密码',
								    blankText: '密码不能为空',
								    name: 'PassWord',
								    emptyText: '密码不能为空',
								    inputType: 'password'
								}
							]
					        ///表单按钮
							, buttons: [{
							    text: '登陆'
									, formBind: true
									, scope: this
									, handler: this.submit
}]
					    }; // eo config object

					    Ext.apply(this, Ext.apply(this.initialConfig, config));
					    Tk.Login.superclass.initComponent.apply(this, arguments);
					}
						, submit: function() {
						    Ext.Ajax.on('beforerequest', this.showSpinner, this);
						    Ext.Ajax.on('requestcomplete', this.closeSpinner, this);
						    Ext.Ajax.request({
						        url: this.url,
						        success: this.someFn,
						        failure: this.someFail,
						        params: { RM: helper.Post("L", Ext.util.JSON.encode(this.getForm().getValues())) }
						    });
						}
						, someFn: function(form, action) {
						    var re = helper.Data(form);
						    if (re.Flag == true) {
						        window.location = "Default.aspx";
						    } else {
						    this.getForm().
						        alert("登陆失败");
						    }
						}
						, someFail: function(form, action) {
						    alert("服务器发生异常");
						}, showSpinner: function() {
						    helper.Prog();
						}, closeSpinner: function() {
						    helper.Hide();
						}

});
Ext.reg('Tk.Login', Tk.Login);

Tk.LoginWin=function(){ 
	var lw=	new Ext.Window({
        width: 350,
        title:'系统登陆',
        height:200,
        layout: 'fit',
        constrain:true,
        closable:true,
        collapsedCls:"x-plain",
        maskDisabled:true,
        bodyStyle:'padding:5px;',
        buttonAlign:'center',
        modal:true,
        items: {xtype:"Tk.Login"}
    })
	return lw;

}